﻿using System;
using System.Windows;
using System.Threading;
using System.Collections.ObjectModel;

// Toolkit namespace
using System.Windows.Input;
using SimpleMvvmToolkit;

// Toolkit extension methods
using SimpleMvvmToolkit.ModelExtensions;
using SpotTheMisspell.Models;

namespace SpotTheMisspell.ViewModels
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvmprop</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// </summary>
    public class StartPageViewModel : ViewModelBase<StartPageViewModel>
    {


        public event EventHandler<NotificationEventArgs<Exception>> ErrorNotice;

        public int NumOfTotalWord { get; set; }
        public int NumOfMisspelled { get; set; }
        public StartPageViewModel()
        {
            NumOfMisspelled = 5;
            NumOfTotalWord = 20;
        }

        
        
        

        public ICommand StartNewGameCommand
        {
           get{  return new DelegateCommand(StartGame);}
        }

        

        private void StartGame()
        {
            SendMessage(MessageToken.StartGame, new NotificationEventArgs<ParagraphDesriber, bool>
                                                          (
                                                              null,
                                                              new ParagraphDesriber()
                                                                  {Misspelled = NumOfMisspelled, Word = NumOfTotalWord},
                                                              null
                                                          ));
            App.Navigator.Navigate("GamePage");
        }

        

        

      
        // Helper method to notify View of an error
        private void NotifyError(string message, Exception error)
        {
            // Notify view of an error
            Notify(ErrorNotice, new NotificationEventArgs<Exception>(message, error));
        }

        
    }
}